<template>
  <div >
    <div>
      <div class="font15 mt10 pl10">
        <span class="titletext ">{{titledata.title}}</span>
        <div class="graytext  mt10 font13">
          <span >工单编号:</span>
          <span class="titletext">{{titledata.pmInsId}}</span>
        </div>
      </div>
      <!-- 基本信息 -->
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">基础信息</span>
      </div>
      <van-field @click="tomsg()" readonly required name="businessId" :value="fromdata.businessId" label-width="5em" label="商机编号：" />
      <van-field autosize type="textarea" rows="1" readonly required name="businessName" :value="fromdata.businessName" label-width="5em" label="商机名称：" />
      <van-field readonly required name="projectEstablishNumber" :value="fromdata.projectEstablishNumber" label-width="5em" label="项目编号：" />
      <van-field autosize type="textarea" rows="1" readonly required name="projectEstablishName" :value="fromdata.projectEstablishName" label-width="5em" label="项目名称：" />
      <van-field readonly required name="competeType" :value="fromdata.competeType" label-width="5em" label="竞争方式：" />
      <van-field readonly required name="projectModel" :value="fromdata.projectModel" label-width="7em" label="项目实施类型：" />
      <van-field readonly name="projectServiceContent" :value="fromdata.projectServiceContent" label="项目实施类型：" label-width="7em" />
      <van-field readonly name="projectType" :value="fromdata.projectType" label="项目类型：" label-width="5em" />
      <van-field readonly required name="contractSerialNumber" :value="fromdata.contractSerialNumber" label="合同流水号：" label-width="6em" />
      <van-field readonly required name="contractType" :value="businessdata.contractType" label="合同类型：" label-width="5em" />
      <div v-if='businessdata.contractType=="收入合同"'>
        <van-field readonly name="isCommoditySales" :value="businessdata.isCommoditySales" label-width="11em" label="是否存在商品销售收入:" />
        <van-field readonly name="mainAgentMode" :value="businessdata.mainAgentMode" label-width="6em" label="主代理模式:" />
      </div>
      <van-field readonly required name="autonomousImplemention" :value="businessdata.autonomousImplemention" label="是否自主实施:"
                 label-width="7em" />
      <van-field readonly required name="autonomousImplementionType" :value="businessdata.autonomousImplementionType" label="项目自主实施类型:"
                 label-width="9em" />
      <van-field v-if="businessdata.autonomousImplemention == '是'" readonly required name="autImplementScope" :value="businessdata.autImplementScope" label="自主实施范围：" label-width="7em"/>
      <van-field readonly required name="projectAutoLevel" :value="businessdata.projectAutoLevel" label="项目自主等级：" label-width="7em"/>
      <!--    <van-field readonly name="contractNumber" :value="businessdata.contractNumber" label="合同编码：" label-width="5em" />-->
      <div v-if='businessdata.contractType=="收入合同"'>
        <van-field readonly required name="supplierCode" :value="businessdata.supplierCode" label-width="7em" label="计费单位编码:" />
        <van-field readonly required name="supplierName" :value="businessdata.supplierName" label-width="7em" label="计费单位名称:" />
        <van-field readonly name="entrustedSalesModel" :value="businessdata.entrustedSalesModel" label="是否受托代销项目:" label-width="9em" />
        <van-field readonly name="supplierCustomerAddress" :value="businessdata.supplierCustomerAddress" label-width="9em" label="集团客户注册地址:" />
        <van-field readonly name="straightCustomrOweFee" :value="businessdata.straightCustomrOweFee" label-width="12em" label="当前客户欠费金额（元）:" />
        <van-field readonly name="supplierCustomerUpDate" :value="businessdata.supplierCustomerUpDate" label-width="9em" label="集团客户成立日期:" />
        <van-field readonly name="supplierCustomerDays" :value="businessdata.supplierCustomerDays" label-width="9em" label="集团客户成立天数:" />
        <van-field readonly name="supplierCustomerScale" :value="businessdata.supplierCustomerScale" label-width="11em" label="客户单位规模（人数）:" />
        <van-field readonly required name="industryBigTypeProvince" :value="businessdata.industryBigTypeProvince" label="省内行业大类：" label-width="7em" />
        <van-field readonly required name="industryBigTypeGroup" :value="businessdata.industryBigTypeGroup" label="集团行业大类：" label-width="7em" />
        <van-field readonly required name="industryMinTypeGroup" :value="businessdata.industryMinTypeGroup" label="集团行业小类：" label-width="7em" />
        <van-field readonly required name="industryName" :value="businessdata.industryName" label="15大行业名称：" label-width="7.5em" />
        <van-field readonly required name="industryNameOneLevel" :value="businessdata.industryNameOneLevel" label="行业一级名称：" label-width="7em" />
        <van-field readonly required name="industryNameTwoLevel" :value="businessdata.industryNameTwoLevel" label="行业二级名称：" label-width="7em" />
      </div>
      <div v-else>
        <van-field readonly name="entrustedSalesModel" :value="businessdata.entrustedSalesModel" label="是否受托代销项目:" label-width="9em" />
      </div>
      <div v-if='businessdata.contractType=="收入合同"'>
        <van-field readonly required name="isVideoNet" :value="businessdata.isVideoNet == 1 ? '是' : '否'" label="是否包含视联网能力:" label-width="11em" />
        <div class="redtext font11" style="margin: 5px 15px 0px 15px;">
          视联网能力说明：当商机内容包含视联网关键字，如“视频、监控、雪亮、应急、摄像头、球机、枪机、千里眼、云视讯、和对讲”等，则选择“是”。
        </div>
        <van-field v-if="businessdata.isVideoNet == 1" readonly required name="videoNetInfoAmount" :value="businessdata.videoNetInfoAmount" label="视联网能力收入金额(含税)(万元):" label-width="11em" />
        <van-field v-if="businessdata.isVideoNet == 1" readonly required name="incomeRate" :value="businessdata.incomeRate" label="视联网能力收入占比(%):" label-width="11em" />
        <van-field v-if="businessdata.isVideoNet == 1" readonly required name="connectionsNum" :value="businessdata.connectionsNum" label="视联网能力连接数:" label-width="9em" />
        <div v-if="businessdata.isVideoNet == 1" class="redtext font11" style="margin: 5px 15px 0px 15px;">
          视联网能力说明：当商机内容包含视联网关键字，如“视频、监控、雪亮、应急、摄像头、球机、枪机、千里眼、云视讯、和对讲”等，则选择“是”。
        </div>
        <!--AI打标签-->
        <van-field readonly required name="isAiAbility" :value="businessdata.isAiAbility == 1 ? '是' : '否'" label="是否包含AI能力:" label-width="8em" />
        <van-field v-if="businessdata.isAiAbility == 1" readonly required name="aiAbilityType" :value="businessdata.aiAbilityType" label="AI能力分类:" label-width="6em" />
        <van-field v-if="businessdata.isAiAbility == 1" readonly required name="aiAbilityAmount" :value="businessdata.aiAbilityAmount" label="AI能力收入金额(含税)(万元):" label-width="14em" />
        <van-field v-if="businessdata.isAiAbility == 1" readonly required name="aiIncomeRate" :value="businessdata.aiIncomeRate" label="AI能力收入占比(%):" label-width="10em" />
        <div class="redtext font11" style="margin: 5px 15px 0px 15px;">
          AI能力说明: 当项目包含各类A业务场景，中是否包含安全产品*如智眉大模型、AI产品、AI行业应用、AI大模型服务等，则选择“是”。
        </div>
        <!--    安全产品-->
        <van-field readonly required name="isSafeProduct" :value="businessdata.isSafeProduct == 1 ? '是' : '否'" label="是否包含安全产品:" label-width="8.5em" />
        <van-field v-if="businessdata.isSafeProduct == 1" readonly required name="safeProductAmount" :value="businessdata.safeProductAmount" label="安全产品收入金额（含税，万元）:" label-width="11em" />
        <van-field v-if="businessdata.isSafeProduct == 1" readonly required name="safeIncomeRate" :value="businessdata.safeIncomeRate" label="安全产品收入占比(%):" label-width="11em" />
        <div class="redtext font11" style="margin: 5px 15px 0px 15px;">
          安全产品说明：当项目包含各类安全业务场景，安全业务场景指：在垂直行业ICT解项目中，提供等保合规类、密码安全类、数据安全类、工业安全类、供应链安全类、云安全类、车联网安全类、5G/6G安全、安全服务（咨询、规划、重保、攻防、应急响应、靶场、培训等）相关产品和支撑服务，帮助客户建立健全信息系统及网络安全防护体系，保护系统和数据不受威胁，提升其安全性、稳定性、可靠性和合规性等，则选择“是”。
        </div>
      </div>
      <!--    <van-field readonly name="entrustedSalesModel" :value="businessdata.entrustedSalesModel" label="是否受托代销项目：" label-width="9em" />-->
      <!-- <van-field readonly required name="contractChangeType" :value="businessdata.contractChangeType" label="合同变更类型：" label-width="7em" />
      <van-field readonly required name="changeAmountTotal" :value="businessdata.changeAmountTotal" label="合同变更最终金额(元)：" label-width="11.5em" /> -->
      <van-field readonly required autosize type="textarea" rows="1" name="changeContractCause" :value="businessdata.changeContractCause" label="变更原因：" label-width="5em" />
      <van-field readonly required label="证明文件：" label-width="5em" />
      <div v-for="(fileitem) in businessdata.changeContractFileList" :key="fileitem.id" style="margin-left:20px">
        <div readonly class="font14 fileLink" style="color:#0F85CF">
          <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
        </div>
      </div>
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">合同发起信息</span>
      </div>
      <van-field readonly required name="contractSerialNumber" :value="fromdata.contractDrawUp.contractSerialNumber" label="合同流水号：" label-width="6em" />
      <van-field readonly  name="contractName" :value="fromdata.contractDrawUp.contractName" label="合同发起名称：" label-width="7em" />
      <van-field readonly  name="incExpTypeValue" :value="incExpTypeValue" label="收支类型：" label-width="5em" />
      <van-field readonly required name="contractAmount" :value="fromdata.contractAmount" label="合同含税总金额(元)：" label-width="10em" />
      <van-field readonly  name="contractNoAmount" :value="businessdata.contractNoAmount" label="合同不含税总金额(元)：" label-width="11em" />
      <van-field readonly  name="isProtocal" :value="fromdata.contractDrawUp.isProtocal=='Y'?'是':'否'" label="是否补充协议：" label-width="7em" />
      <div v-if='businessdata.contractType=="收入合同"'>
        <van-field readonly  name="associateNo" :value="fromdata.contractDrawUp.associateNo" label="关联合同编号：" label-width="7em" />
        <van-field readonly  name="protocalType" :value="fromdata.contractDrawUp.protocalType" label="补充协议类型：" label-width="7em" />
        <van-field readonly  name="influenceScope" :value="fromdata.contractDrawUp.influenceScope" label="影响合同计划范围：" label-width="9em" />
      </div>
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">合同计划管理</span>
      </div>
      <van-field readonly required name="contractPlanType" :value="businessdata.contractPlanType" label="合同计划类型：" label-width="7em" />
      <div v-if='businessdata.contractType=="收入合同"'>
        <van-field readonly  name="splitIncludedAmountTotal2" :value="splitIncludedAmountTotal2" label="收入拆分含税总金额合计(元)：" label-width="14em" />
        <van-field readonly required name="contractNoMoneyIncome" :value="businessdata.contractNoMoneyIncome" label="收入拆分不含税总金额合计(元)：" label-width="15em" />
        <van-field readonly  name="paymentLimitTotal2" :value="paymentLimitTotal2" label="收款含税额度合计(元)：" label-width="11em" />
        <van-field readonly required name="itAmount" :value="businessdata.itAmount" label="IT收入金额(含税元)：" label-width="11em" />
        <van-field readonly required name="itUniversalAmount" :value="businessdata.itUniversalAmount" label="IT通服收入金额(含税元)：" label-width="12em" />
        <van-field readonly  name="incomePlanDeviation" :value="businessdata.incomePlanDeviation" label="收入合同签约额与收入计划偏差(%)：" label-width="17em" />
        <van-field readonly required name="itNoAmount" :value="businessdata.itNoAmount" label="IT收入金额(不含税元)：" label-width="11em" />
        <van-field readonly required name="itUniversalNoAmount" :value="businessdata.itUniversalNoAmount" label="IT通服收入金额(不含税元)：" label-width="13em" />
        <van-field readonly  name="rateProductImplantationOwn" :value="businessdata.rateProductImplantationOwn" label="自有产品植入率：" label-width="8em" />
        <van-field readonly  name="rateProductImplantation" :value="businessdata.rateProductImplantation" label="自研产品植入率：" label-width="8em" />
      </div>
      <div v-else>
        <van-field readonly  name="splitIncludedAmountTotal" :value="businessdata.splitIncludedAmountTotal" label="支出拆分含税总金额合计(元)：" label-width="14em" />
        <van-field readonly required name="contractNoMoneyOutcome" :value="contractNoMoneyOutcome" label="支出拆分不含税总金额合计(元)：" label-width="15em" />
        <van-field readonly  name="paymentLimitTotal" :value="businessdata.paymentLimitTotal" label="付款含税额度合计(元)：" label-width="11em" />
        <van-field readonly required name="outContractNoMoneyIt" :value="outContractNoMoneyIt" label="合同计划IT金额(不含税元)：" label-width="13em" />
        <van-field readonly  name="outContractNoMoneyCt" :value="outContractNoMoneyCt" label="合同计划CT金额(不含税元)：" label-width="13em" />
        <van-field readonly required name="outcomePlanDeviation" :value="businessdata.outcomePlanDeviation" label="支出合同签约额与支出计划偏差(%)：" label-width="17em" />
      </div>
      <!--    <van-field v-if='businessdata.contractType=="收入合同"' readonly name="splitIncludedAmountTotal" :value="businessdata.splitIncludedAmountTotal" label="拆分含税总金额合计(元)：" label-width="12em" />-->
      <!--    <van-field v-if='businessdata.contractType=="收入合同"' readonly name="paymentLimitTotal" :value="businessdata.paymentLimitTotal" label="收付款含税收付款额度合计(元)：" label-width="15em" />-->
      <historyAndSuggs id='target' :showHistory='showHistory'
                       :historydata='historydata' :approveList='approveList' />
    </div>


  </div>
</template>
 
<script>
import { openFileUrl } from '@/store/openFile'
import historyAndSuggs from "@/views/srqr/historyAndSuggs.vue"
import {Notify} from "vant";
import {queryByType} from '@/api/dictapi'
export default {
  data() {
    return {
      showUpAndDownPop:false, 
      UpAndDownPopColumns:['是', '否'],
      showCalculateModePop:false, 
      CalculateModePopColumns:['主理人', '代理人'],
      showIsAttentionPop:false, 
      IsAttentionPopColumns:['是', '否'],
      incExpTypeValue:'',
      splitIncludedAmountTotal2:0,
      paymentLimitTotal2:0,
      contractNoMoneyOutcome:0,
      outContractNoMoneyIt:0,
      outContractNoMoneyCt:0,
    }
  },
  props: ['titledata','businessdata','fromdata','showHistory','historydata','approveList'],
  watch: {
    fromdata: {
      handler () { //这是vue的规定写法，当你watch的值发生变化的时候，就会触发这个handler，这是vue内部帮你做的事情
        this.getTypeValue();
      },
      deep: true,  // 可以深度检测到 obj 对象的属性值的变化
      immediate: true //刷新加载  立马触发一次handler
    }
  },
  methods: {
     tomsg () {
      document.getElementById('target').scrollIntoView({ behavior: 'smooth' })
    },
    openFileUrlfun(value) {
      this.$router.push(
        {
          name: 'fileview',
          query: {
            openFileUrl: openFileUrl(value)
          }
        }
      );
    },
    getTypeValue(){
      //收支类型
      if (this.fromdata.contractDrawUp?.incExpType){
        queryByType({ dictType:'incExpType'} )
            .then((result) => {
              if (!result.data) {
                Notify(result.message);
                return;
              }
              for(var i=0;i<result.data.data.length;i++){
                if(result.data.data[i].value==this.fromdata.contractDrawUp?.incExpType){
                  console.log('111111111111111')
                  this.incExpTypeValue = result.data.data[i].name;
                }
              }
            })
      }
      if (this.businessdata.contractType=="收入合同"){
        //实时计算部分金额
        let ctAndIt_number1=0
        var itList_number1=0
        var ctList_number1=0
        for (var i=0;i<this.fromdata.incomeModelList.length;i++) {
          if(this.fromdata.incomeModelList[i].contractPartType=='IT'){
            itList_number1=Number(itList_number1)+Number(this.fromdata.incomeModelList[i].splitIncludedAmount)
          }else{
            ctList_number1=Number(ctList_number1)+Number(this.fromdata.incomeModelList[i].splitIncludedAmount)
          }
          ctAndIt_number1=Number(ctAndIt_number1)+Number(this.fromdata.incomeModelList[i].splitIncludedAmount)
        }
        this.paymentLimitTotal2=ctAndIt_number1.toFixed(2)
        let payeeList_number=0
        for (var i=0;i<this.fromdata.payeeModelList.length;i++) {
          payeeList_number=Number(payeeList_number)+Number(this.fromdata.payeeModelList[i].paymentLimit)
        }
        this.splitIncludedAmountTotal2=payeeList_number.toFixed(2)
      }else {
        //实时计算部分金额
        let noMoneyOutcome=0
        var itList_number1=0
        var ctList_number1=0
        for (var i=0;i<this.fromdata.outcomeModelList.length;i++) {
          if(this.fromdata.outcomeModelList[i].contractPartType=='IT'){
            itList_number1=Number(itList_number1)+Number(this.fromdata.outcomeModelList[i].splitNoAmount)
          }else{
            ctList_number1=Number(ctList_number1)+Number(this.fromdata.outcomeModelList[i].splitNoAmount)
          }
          noMoneyOutcome=Number(noMoneyOutcome)+Number(this.fromdata.outcomeModelList[i].splitNoAmount)
        }
        this.contractNoMoneyOutcome=noMoneyOutcome.toFixed(2)
        this.outContractNoMoneyIt=itList_number1.toFixed(2)
        this.outContractNoMoneyCt=ctList_number1.toFixed(2)
      }
    }
  },
  computed: {
    isCWSPLocation: function () {
      return this.location=='dict.accountingApproval'
    },
  },
  components: {
    historyAndSuggs
  },
}
</script>
 
<style>
.tables.el-table .cell {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    line-height: 15px;
    padding-left: 5px;
    padding-right: 5px;
}
</style>